package com.ims.core.saleconfig.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.saleconfig.domain.TSalConfig;
import com.ims.core.saleconfig.service.ITSalConfigService;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 销项系统配置Controller
 *
 * @author IMS
 * @date 2024-05-19
 */
@RestController
@RequestMapping("/saleconfig/config")
public class TSalConfigController extends BaseController
{
    @Autowired
    private ITSalConfigService tSalConfigService;

    /**
     * 查询销项系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSalConfig tSalConfig)
    {
        startPage();
        List<TSalConfig> list = tSalConfigService.selectTSalConfigList(tSalConfig);
        return getDataTable(list);
    }

    /**
     * 导出销项系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:export')")
    @Log(title = "销项系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TSalConfig tSalConfig)
    {
        List<TSalConfig> list = tSalConfigService.selectTSalConfigList(tSalConfig);
        ExcelUtil<TSalConfig> util = new ExcelUtil<TSalConfig>(TSalConfig.class);
        util.exportExcel(response, list, "销项系统配置数据");
    }

    /**
     * 获取销项系统配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tSalConfigService.selectTSalConfigById(id));
    }

    /**
     * 新增销项系统配置
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:add')")
    @Log(title = "销项系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSalConfig tSalConfig)
    {
        return toAjax(tSalConfigService.insertTSalConfig(tSalConfig));
    }

    /**
     * 修改销项系统配置
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:edit')")
    @Log(title = "销项系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSalConfig tSalConfig)
    {
        return toAjax(tSalConfigService.updateTSalConfig(tSalConfig));
    }

    /**
     * 删除销项系统配置
     */
    @PreAuthorize("@ss.hasPermi('saleconfig:config:remove')")
    @Log(title = "销项系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tSalConfigService.deleteTSalConfigByIds(ids));
    }
}
